﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Global.Master" AutoEventWireup="true" CodeBehind="SiteBulletin.aspx.cs" Inherits="klcc.Apps.Manage.PostBoard" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .post, .post td {
            border: 1px solid #000;
            border-collapse: collapse;
        }
        .post input, .post textarea 
        {
            width: 100%;
        }
        .post input[type="submit"]
        {
            width: 100px;
        }
        .item_name
        {
            border: 1px solid #666;
            padding: 3px;
        }
    </style>
    <script type="text/javascript" src="../../Scripts/lib/jquery.js"></script>
    <script type="text/javascript">
        $(document).ready(init);

        function init() {
            $('#add_table').hide();
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
        <div id="show">新增</div>
        <div id="add_table">
        
        <table class="post">
            <tr>
                <td class="item_name" width="100">標題</td>
                <td width="700">
                    <asp:TextBox ID="TitleText" runat="server"></asp:TextBox></td>
            </tr>
            <tr>
                <td colspan="2" class="item_name">
                    公告內容</td>
            </tr>
            <tr>
                <td colspan="2">
                    <asp:TextBox ID="ContentText" runat="server" Height="150px" 
                        TextMode="MultiLine"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td colspan="2" class="item_name">
                    備註</td>
            </tr>
            <tr>
                <td colspan="2">
                    <asp:TextBox ID="OtherText" runat="server" Height="100px" TextMode="MultiLine"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td colspan="2" class="item_name">
                    附加檔案</td>
            </tr>
            <tr>
                <td colspan="2">
                    &nbsp;</td>
            </tr>
            <tr>
                <td colspan="2" class="item_name">
                    電子郵件通知(一行一個)</td>
            </tr>
            <tr>
                <td colspan="2">
                    <asp:TextBox ID="MailTo" runat="server" Height="100px" TextMode="MultiLine"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td colspan="2" align="right">
                    <asp:Button ID="SendDataBTN" runat="server" Text="送出" 
                        onclick="SendDataBTN_Click" />
                </td>
            </tr>
        </table>
        </div>
        <div id="list">
        
            <asp:GridView ID="SiteBulletinGV" runat="server" 
    AutoGenerateColumns="False" CellPadding="4" DataKeyNames="SiteBulletinId" 
    DataSourceID="SiteBulletinDS" ForeColor="#333333" GridLines="None" 
    Width="800px">
                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                <Columns>
                    <asp:BoundField DataField="SiteBulletinId" 
                HeaderText="SiteBulletinId" ReadOnly="True" SortExpression="SiteBulletinId" 
                Visible="False" />
                    <asp:BoundField DataField="UserId" HeaderText="UserId" 
                SortExpression="UserId" Visible="False" />
                    <asp:BoundField DataField="Title" HeaderText="Title" 
                SortExpression="Title" />
                    <asp:BoundField DataField="ContentText" 
                HeaderText="ContentText" SortExpression="ContentText" Visible="False" />
                    <asp:BoundField DataField="OtherText" 
                HeaderText="OtherText" SortExpression="OtherText" Visible="False" />
                    <asp:BoundField DataField="MailTo" HeaderText="MailTo" 
                SortExpression="MailTo" Visible="False" />
                    <asp:BoundField DataField="Files" HeaderText="Files" 
                SortExpression="Files" Visible="False" />
                </Columns>
                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" 
            ForeColor="White" />
                <PagerStyle BackColor="#284775" ForeColor="White" 
            HorizontalAlign="Center" />
                <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" 
            ForeColor="#333333" />
                <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" 
            ForeColor="White" />
                <EditRowStyle BackColor="#999999" />
                <AlternatingRowStyle BackColor="White" 
            ForeColor="#284775" />
            </asp:GridView>
            </div>
        <asp:SqlDataSource ID="SiteBulletinDS" runat="server" 
        ConnectionString="<%$ ConnectionStrings:KlccConnectionString %>" 
        SelectCommand="SELECT * FROM [SiteBulletins] ORDER BY PostTime DESC" 
                InsertCommand="INSERT INTO SiteBulletins(UserId, Title, ContentText, OtherText, MailTo) VALUES (@userid,@title,@content,@other,@mailto)">
            <InsertParameters>
                <asp:ControlParameter ControlID="TitleText" Name="title" PropertyName="Text" />
                <asp:ControlParameter ControlID="ContentText" Name="content" 
                    PropertyName="Text" />
                <asp:ControlParameter ControlID="OtherText" Name="other" PropertyName="Text" />
                <asp:ControlParameter ControlID="MailTo" Name="mailto" PropertyName="Text" />
                <asp:SessionParameter Name="userid" SessionField="UserId" />
            </InsertParameters>
            </asp:SqlDataSource>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
